home *** CD-ROM | disk | FTP | other *** search
- /* merge1.c - external sort for a text file */
- #include "stdio.h"
- #include "cminor.h"
- #include "merge1.h"
-
- int (*compfun) () ; /* address of compare function */
- int strcmp() ; /* library string compare function */
- char scra[68] = "scra" ; /* prefixes for each word */
- char scrb[68] = "scrb" ;
-
- main(argc,argv)
- int argc ; /* number of words in command line */
- char *argv[] ; /* pointers to each word */
- {
- /* check to see that file names were specified */
- if( argc < 3 )
- { printf(" need file names \n") ;
- printf(" USAGE: merge1 input-file output-file \n") ;
- exit( 1 ) ;
- }
- compfun = strcmp ; /* use strings compare function */
- dosort(argv[1],argv[2]) ;
- }
-
-
- int dosort(fromfile,tofile)
- char fromfile[] ; /* input for sort */
- char tofile[] ; /* put the output here */
- {
- int nruns ;
- /* form runs from input file */
- nruns = formruns(fromfile,scra,tofile) ;
- /* now merge runs */
- domerge(scra,scrb,tofile,nruns) ;
- }
-
-